Skip to content

Conversation

devin-ai-integration[bot]
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Oct 9, 2025

Add bulk_insert parameter to executemany() for improved INSERT performance

Summary

Adds a new bulk_insert parameter to the executemany() method in both sync and async cursors. When enabled, this feature concatenates multiple INSERT statements into a single batch request with merge_prepared_statement_batches=true, providing significant performance improvements for large data insertions.

Key Changes:

  • Added bulk_insert parameter (defaults to False for backward compatibility)
  • Validates queries are INSERT statements only
  • Supports both QMARK (?) and FB_NUMERIC ($1, $2) parameter styles
  • Concatenates queries with semicolons for batch execution
  • Comprehensive unit and integration test coverage
  • Updated documentation with usage examples

Review & Testing Checklist for Human

Critical items requiring manual verification:

  • End-to-end database testing: Test bulk insert with real Firebolt database using both parameter styles to verify actual performance improvements and correctness
  • Parameter binding validation: Verify complex data types (dates, decimals, strings with special characters) are correctly bound in both QMARK and FB_NUMERIC modes
  • Error handling verification: Test edge cases including non-INSERT queries, empty parameter lists, malformed queries, and large datasets to ensure proper error messages and cursor state management
  • Security review: Verify query concatenation and parameter handling doesn't introduce SQL injection vulnerabilities, especially with user-provided data

Session Info: Implemented by Devin AI for @ptiurin
Session URL: https://app.devin.ai/sessions/45091a6335424e0798501799fd55a858

Copy link
Contributor Author

devin-ai-integration bot commented Oct 9, 2025

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@ptiurin ptiurin changed the title feat: add bulk_insert parameter to executemany for improved INSERT performance feat(NoTicket): add bulk_insert parameter to executemany for improved INSERT performance Oct 9, 2025
devin-ai-integration bot added a commit that referenced this pull request Oct 10, 2025
…n logic

- Replace sqlparse with simple string checks in _validate_bulk_insert_query
- Add extra_params parameter to _build_fb_numeric_query_params for extensibility
- Refactor _executemany_bulk_insert to preprocess and delegate to existing methods
- Use TimeoutController for consistent timeout handling
- Parametrize integration tests to avoid duplication

Addresses PR feedback from ptiurin on #463

Co-Authored-By: petro.tiurin@firebolt.io <petro.tiurin@firebolt.io>
devin-ai-integration bot added a commit that referenced this pull request Oct 10, 2025
- Move firebolt.db and firebolt.async_db imports to top of test files
- Remove local import statements from inside test functions
- Use full module names instead of local aliases

Addresses final PR feedback from ptiurin on #463

Co-Authored-By: petro.tiurin@firebolt.io <petro.tiurin@firebolt.io>
devin-ai-integration bot added a commit that referenced this pull request Oct 13, 2025
- Remove QMARK parameter style example from bulk_insert documentation
- Update note to explicitly state bulk_insert requires fb_numeric
- Clarify that using other parameter styles will raise an error

Addresses PR feedback from ptiurin on #463

Co-Authored-By: petro.tiurin@firebolt.io <petro.tiurin@firebolt.io>
devin-ai-integration bot and others added 12 commits October 14, 2025 14:11
…rformance

- Add bulk_insert flag to executemany() in both sync and async cursors
- Concatenate multiple INSERT queries with semicolons when bulk_insert=True
- Send with merge_prepared_statement_batches=true query parameter
- Support both QMARK and FB_NUMERIC parameter styles
- Add validation to ensure only INSERT statements use bulk_insert
- Add comprehensive unit tests for both sync and async cursors
- Add integration tests for V2 (sync and async)
- Add documentation with examples for both parameter styles

Co-Authored-By: petro.tiurin@firebolt.io <petro.tiurin@firebolt.io>
Co-Authored-By: petro.tiurin@firebolt.io <petro.tiurin@firebolt.io>
…meters

Co-Authored-By: petro.tiurin@firebolt.io <petro.tiurin@firebolt.io>
Co-Authored-By: petro.tiurin@firebolt.io <petro.tiurin@firebolt.io>
Co-Authored-By: petro.tiurin@firebolt.io <petro.tiurin@firebolt.io>
Co-Authored-By: petro.tiurin@firebolt.io <petro.tiurin@firebolt.io>
…n logic

- Replace sqlparse with simple string checks in _validate_bulk_insert_query
- Add extra_params parameter to _build_fb_numeric_query_params for extensibility
- Refactor _executemany_bulk_insert to preprocess and delegate to existing methods
- Use TimeoutController for consistent timeout handling
- Parametrize integration tests to avoid duplication

Addresses PR feedback from ptiurin on #463

Co-Authored-By: petro.tiurin@firebolt.io <petro.tiurin@firebolt.io>
- Move firebolt.db and firebolt.async_db imports to top of test files
- Remove local import statements from inside test functions
- Use full module names instead of local aliases

Addresses final PR feedback from ptiurin on #463

Co-Authored-By: petro.tiurin@firebolt.io <petro.tiurin@firebolt.io>
- Remove QMARK parameter style example from bulk_insert documentation
- Update note to explicitly state bulk_insert requires fb_numeric
- Clarify that using other parameter styles will raise an error

Addresses PR feedback from ptiurin on #463

Co-Authored-By: petro.tiurin@firebolt.io <petro.tiurin@firebolt.io>
@ptiurin ptiurin force-pushed the devin/1760003599-bulk-insert-executemany branch from 49854e4 to 97b5c56 Compare October 14, 2025 16:24
Copy link

@ptiurin ptiurin changed the base branch from main to refactor-query-preparation October 14, 2025 16:32
@ptiurin ptiurin changed the title feat(NoTicket): add bulk_insert parameter to executemany for improved INSERT performance feat(FIR-49930): add bulk_insert parameter to executemany for improved INSERT performance Oct 15, 2025
@ptiurin ptiurin marked this pull request as ready for review October 15, 2025 16:39
@ptiurin ptiurin requested a review from a team as a code owner October 15, 2025 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant